package org.wanda.pv.model.basic;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import org.wanda.pv.framework.base.BaseModel;

import java.util.List;

/**
 * @author lxy
 * @date 2018/11/15 11:34
 */

@Comment("设计系统")
@Table("wd_system")
public class System extends BaseModel{
    @Column
    @Id
    @Prev(els = {@EL("$me.idGen()")})
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Comment("设计系统名称")
    @Column("system_name")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String name;

    @Comment("专业分类表的ID")
    @Column("specialty_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long specialtyId;


    @Many(field = "systemId")
    private List<Point> points;

    @Many(field = "systemId")
    private List<TopPoint> topPoints;

    @One(field = "specialtyId")
    private Specialty category;

    @Comment("系统下要点个数")
    private int pointCount;

    @Column
    @Comment("排序字段")
    @Prev({
            @SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM wd_system"),
            @SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM wd_system")
    })
    private Integer location;

    public List<TopPoint> getTopPoints() {
        return topPoints;
    }

    public void setTopPoints(List<TopPoint> topPoints) {
        this.topPoints = topPoints;
    }

    public Integer getLocation() {
        return location;
    }

    public void setLocation(Integer location) {
        this.location = location;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getSpecialtyId() {
        return specialtyId;
    }

    public void setSpecialtyId(Long specialtyId) {
        this.specialtyId = specialtyId;
    }

    public List<Point> getPoints() {
        return points;
    }

    public void setPoints(List<Point> points) {
        this.points = points;
    }

    public Specialty getCategory() {
        return category;
    }

    public void setCategory(Specialty category) {
        this.category = category;
    }

    public int getPointCount() {
        return pointCount;
    }

    public void setPointCount(int pointCount) {
        this.pointCount = pointCount;
    }
}
